<?php  if (!defined("IS_INITPHP")) exit("Access Denied!");  /* INITPHP Version 1.0 ,Create on 2016-03-18 09:14:41, compiled from ../app/web/template/index/index.htm */ ?>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
<script src="http://static.joyowo.com/lib/jquery/1.11.1/jquery.min.js"></script>
<script src="http://static.joyowo.com/lib/cmd-plugins/artDialog/6.0.2/dialog.min.js"></script>
<link href="http://static.joyowo.com/lib/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://static.joyowo.com/lib/cmd-plugins/artDialog/6.0.2/ui-dialog.min.css">
 </head>
 
 <body>
<style type="text/css">
.personinfo > td{
	vertical-align: middle !important;
}
.select-style {
	width: 200px;
	height: 30px;
}
.error {
	color: red;
}
.ml0 {
	margin-left: 0px;
}
</style>


<div class="container">
	<div class="panel">
		<div class="panel-body">			
		    <table class="table table-bordered text-center table-hover">
		        <thead>
		            <tr>
		                <td>姓名</td>
		                <td>年假剩余（天）</td>
		                <td>调休剩余（天）</td>
		                <td>操作</td>
		            </tr>
		        </thead>
		        <tbody>
		        <?php  if(!empty($staff_data)){  ?>
		        <?php   foreach($staff_data as $key=>$value){  ?>
		            <tr class="personinfo">
		                <td><?php  echo $value['name']  ?></td>
		                <td><?php  echo $value['annual_holiday']  ?></td>
		                <td><?php  echo $value['tone_rests']  ?></td>
		                <td>
		                    <a data-id="<?php  echo $value['id']  ?>" href="javascript:void(0)" class="btn btn-primary check-log">日志</a>
		                    <?php  if(!empty($operate_user)){  ?>
		                    &nbsp;/&nbsp;
		                    <a data-id="<?php  echo $value['id'];  ?>" data-name="<?php  echo $value['name'];  ?>" data-user="<?php  echo $operate_user;  ?>" href="javascript:void(0)" class="btn btn-primary edit-restecord">编辑</a>
		                		<?php  }  ?>
		                </td>
		            </tr>
		            <?php  }  ?>
		            <?php  }  ?>
		        </tbody>
		    </table>			
		</div>	
	</div>	
</div>

<script type="text/html" id="editlog">	
    <form class="form-horizontal register-form">       
        	<div class="form-group">
                <label for="selcetTypes" class="col-sm-offset-1 col-sm-3 control-label">类别：</label>
                <div class="col-sm-5">
                    <select class="form-control select-types"  id="selcetTypes" name="selcetTypes">
                    	<option value="0">年假</option>
                    	<option value="1" selected>调休</option>
                    </select>                  
                </div>
            </div>
            <div class="form-group">
                <label for="select" class="col-sm-offset-1 col-sm-3 control-label">增减：</label>
                <div class="col-sm-5">
                    <select class="form-control select" id="selcet" name="select">
                    	<option value="0" selected>增加</option>
                    	<option value="1">减少</option>
                    </select>                  
                </div>
            </div>
            <div class="form-group" id="annual">
                <label for="days" class="col-sm-offset-1 col-sm-3 control-label">天数：</label>
                <div class="col-sm-5">                  
                    <input type="text" class="form-control" id="days" name="days" placeholder="">                                             
                </div>
            </div>
            <div class="form-group">
            	<label for="remark" class="col-sm-offset-1 col-sm-3 control-label">备注：</label>
            	<div class="col-sm-5">
            		<input type="text" class="form-control" id="remark">
            	</div>
            </div>          
    </form>
</script>
<script type="text/javascript">
/**
 * @return {[type]}
 */
$(".check-log").click(function(){
	var _id = $(this).attr('data-id');
	
	$.ajax({
		'url': "<?php  echo InitPHP::getConfig('url').'index/index/getLogs';  ?>",
		'type': 'post',
		'dataType': 'json',
		'data': {
			'id': _id
		},
		success: function(d){

			
			var _tr = '';
			
			$.each(d.list, function(i, _obj){
				_tr += '<tr>'+
							'<td>'+ _obj.text +'</td>'+
							'<td>'+ _obj.remark +'</td>'+
							'<td>'+ _obj.time +'</td>'+
						'</tr>';
			})
			
			var _table = '<table class="table table-hover" style="margin-left: 0px">'+
							'<thead>'+
								'<tr>'+
									'<td>操作</td>'+
									'<td>备注</td>'+
									'<td>时间</td>'+
								'</tr>'+
							'</thead>'+
							'<tbody>'+
							_tr +
							'</tbody>'+
						'</table>';
			new dialog({
				button: [
					{
						value: '确定',
						autofocus: true
					}
				],
				title: "日志详情",
				content: _table,
				width: 'auto',
				height:'auto'
			}).showModal();
		}
	})
   });
/**
 * 编辑弹出框
 */
$('.edit-restecord').click(function() {
	var _id = $(this).attr('data-id');
	var _name = $(this).attr('data-name');
	var _user = $(this).attr('data-user');
	
	new dialog({
		button: [
			{
				value: '确定',
				autofocus: true,
				callback: function (){
					$.ajax({
						'url': "<?php  echo InitPHP::getConfig('url').'index/index/operateLogs';  ?>",
						'type': 'post',
						'dataType': 'json',
						data: {
							id:_id,
							staff_name:_name,
							user:_user,
							selectType: $('#selcetTypes').val(),
							select: $('#selcet').val(),
							days: $('#days').val(),
							remark: $('#remark').val()
						},
						success: function(d){
							if(d.status==0){
								alert('增减成功');
							}else{
								alert('增减失败:'+d.msg);
							}
							window.location.reload();
						}
					})
					
					return false;
					
				}
			},
			{
				value: '取消'
			}
		],
		title: "编辑",
		content: $('#editlog').html(),
		width: 500,
		height:'auto'
	}).showModal();
});
</script>
</body>
</html>
